import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  //  {
  //   title: '单据类型ID',
  //   align:"center",
  //   dataIndex: 'billTypeId'
  //  },
   {
    title: '单据类型',
    align:"center",
    dataIndex: 'billTypeName'
   },
   {
    title: '单据编号',
    align:"center",
    sorter: true,
    dataIndex: 'billCode'
   },
  //  {
  //   title: '收货组织ID',
  //   align:"center",
  //   dataIndex: 'receivingOrganizationId'
  //  },
   {
    title: '调入组织',
    align:"center",
    dataIndex: 'storageOrganizationName'
   },
  //  {
  //   title: '供应商ID',
  //   align:"center",
  //   dataIndex: 'supplierId'
  //  },
  //  {
  //   title: '供应商',
  //   align:"center",
  //   dataIndex: 'supplierName'
  //  },
  //  {
  //   title: '仓库ID',
  //   align:"center",
  //   dataIndex: 'warehouseId'
  //  },
   {
    title: '调入储存地点',
    align:"center",
    dataIndex: 'storageWarehouseName'
   },
  //  {
  //   title: '来源类别ID',
  //   align:"center",
  //   dataIndex: 'sourceCategoryId'
  //  },
   {
    title: '来源类别',
    align:"center",
    dataIndex: 'sourceCategoryName'
   },
   {
    title: '调出方向',
    align:"center",
    dataIndex: 'transferDirection'
   },
  //  {
  //   title: '客户ID',
  //   align:"center",
  //   dataIndex: 'customerId'
  //  },
  //  {
  //   title: '客户',
  //   align:"center",
  //   dataIndex: 'customerName'
  //  },
  //  {
  //   title: '库管员',
  //   align:"center",
  //   sorter: true,
  //   dataIndex: 'warehouseKeeper'
  //  },
  //  {
  //   title: '来源单据ID',
  //   align:"center",
  //   dataIndex: 'srcBillId'
  //  },
   {
    title: '来源单据编号',
    align:"center",
    sorter: true,
    dataIndex: 'srcBillCode'
   },
   {
    title: '业务日期',
    align:"center",
    sorter: true,
    dataIndex: 'businessDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
   },
  //  {
  //   title: '收货部门ID',
  //   align:"center",
  //   dataIndex: 'receivingDepartmentId'
  //  },
  //  {
  //   title: '收货部门',
  //   align:"center",
  //   dataIndex: 'receivingDepartmentName'
  //  },
   {
    title: '单据状态',
    align:"center",
    dataIndex: 'billStatus',
    width: 100,
    customRender:({text}) =>{
      return text==0?'开立':text==1?'审核':text==-1?'作废':''
    },
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   {
    title: '第三方编码',
    align:"center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "单据类型",
      field: "billTypeName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "调入组织",
      field: "storageOrganizationName",
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "业务日期",
      field: "businessDate",
      component: 'DatePicker',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '单据类型ID',
    field: 'billTypeId',
    component: 'Input',
    show:false
  },
  {
    label: '单据类型',
    field: 'billTypeName',
    component: 'Input',
    slot:'billTypeSlot',
    dynamicRules: () => {
      return [
        { required: true, message: '请选择单据类型!' },
      ];
    },
  },
  {
    label: '单据编号',
    field: 'billCode',
    component: 'Input',
  },
  {
    label: '调入组织ID',
    field: 'storageOrganizationId',
    component: 'Input',
    show:false
  },
  {
    label: '调入组织',
    field: 'storageOrganizationName',
    component: 'Input',
    slot:'receivingOrganizationSlot'
  },

  {
    label: '调入仓库ID',
    field: 'storageWarehouseId',
    component: 'Input',
    show:false
  },
  {
    label: '调入仓库',
    field: 'storageWarehouseName',
    component: 'Input',
    slot:'warehouseSlot'
  },
  {
    label: '来源类别ID',
    field: 'sourceCategoryId',
    component: 'Input',
    show:false
  },
  {
    label: '来源类别',
    field: 'sourceCategoryName',
    component: 'Input',
  },
  {
    label: '来源单据ID',
    field: 'srcBillId',
    component: 'Input',
    show:false
  },
  {
    label: '来源单据编号',
    field: 'srcBillCode',
    component: 'Input',
  },
  {
    label: '业务日期',
    field: 'businessDate',
    component: 'DatePicker',
  },
  {
    label: '调拨方向',
    field: 'transferDirection',
    component: 'Select',    
    componentProps: {
      options: [{ label: '普通', value: 0 }]
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];
//子表单数据
//子表表格配置
export const busMiscellaneousStorageItemColumns: JVxeColumn[] = [
    {
      title: '调拨入库ID',
      key: 'miscellaneousStorageId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '行号',
      key: 'rowNum',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料品ID',
      key: 'materialId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '料品编号',
      key: 'materialCode',
      type: JVxeTypes.slot,
      slotName:'materialSlot',
      width:"200px",
    },
    {
      title: '料品',
      key: 'materialName',
      type: JVxeTypes.normal,
      width:"200px",
    },
    {
      title: '单位ID',
      key: 'unitId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
  {
    title: '单位',
    key: 'unitName',
    width: "200px",
    type: JVxeTypes.normal,
  },
    {
      title: '数量',
      key: 'quantity',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '单价',
      key: 'price',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '成本',
      key: 'cost',
      type: JVxeTypes.inputNumber,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '仓库ID',
      key: 'storageWarehouseId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '仓库',
      key: 'storageWarehouseName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '仓位ID',
      key: 'storageWarehouseLocationId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '仓位',
      key: 'storageWarehouseLocationName',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '取价来源',
      key: 'pricingSource',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '批号',
      key: 'batchNumber',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据ID',
      key: 'srcBillId',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '来源单据编号',
      key: 'srcBillCode',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '备注',
      key: 'remark',
      type: JVxeTypes.input,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },
    {
      title: '第三方编码',
      key: 'thirdPartyCode',
      type: JVxeTypes.hidden,
      width:"200px",
      placeholder: '请输入${title}',
      defaultValue:'',
    },


  ]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}